pub trait App: Sized + 'static {
	type Error: std::error::Error;
	type Ref<'a>: AppRef;
	fn with(_: impl FnOnce(Self::Ref<'_>));
	fn run(_: impl AppRep<Self>) -> Result<(), Self::Error>;
}
pub trait AppRep<A: App>: 'static {
	fn on_launch(&self, _: A::Ref<'_>) {}
	fn on_terminate(&self, _: A::Ref<'_>) {}
	fn on_low_memory(&self, _: A::Ref<'_>) {}
}
pub trait AppRef {
	type Proxy: AppProxy;
	fn exit(&self);
	fn proxy(&self) -> Self::Proxy;
}
pub trait AppProxy: Sized + Send + Sync + 'static {
	fn wake(&self, id: i64);
	fn to_waker(self, id: i64) -> core::task::Waker {
		struct AppWaker<T: AppProxy>(T, i64);
		impl<T: AppProxy> std::task::Wake for AppWaker<T> {
			fn wake(self: std::sync::Arc<Self>) {
				self.0.wake(self.1);
			}
		}
		std::sync::Arc::new(AppWaker(self, id)).into()
	}
}
